Skip to content

Fix/add missing func#276

Merged
ogarciarevett merged 13 commits intomainfrom
fix/add-missing-func
Feb 4, 2026
Merged

Fix/add missing func#276
ogarciarevett merged 13 commits intomainfrom
fix/add-missing-func

Conversation

@ogarciarevett
Copy link
Collaborator

Issue: Missing func with new treasuries for nfts

🐵 Description

This pull request introduces several important changes to the deployment configuration, contract logic, and developer tooling for the project. The updates improve deployment flexibility for new contracts, enhance whitelist management in the upgradeable ERC contract, and add useful scripts for testing and setup. Below are the most significant changes grouped by theme:

Deployment Configuration and Contract Arguments

  • Added deployment and initialization configuration for the GReceipts contract on Arbitrum One, including its constructor arguments and upgrade settings in both deployments-arbitrum-one.ts and upgrades/index.ts. This enables automated deployment and upgrade management for GReceipts alongside GUnits. [1] [2] [3] [4]
  • Updated token addresses and constructor arguments for Arbitrum Sepolia and Arbitrum One, including new addresses for GUNITS_ARBITRUM_SEPOLIA, GUNITS_ARBITRUM_ONE, and USDXM_ARBITRUM_SEPOLIA. Adjusted GUnitsArgs to use the correct payment tokens for each network. [1] [2]

Upgradeable Contract Logic

  • Enhanced the ERCWhitelistSignatureUpgradeable contract to maintain an explicit list of whitelist signers, enabling enumeration and improved management. Added logic to update this list when signers are added or removed, and exposed an internal getter for the list. [1] [2] [3]

Developer Tooling and Scripts

  • Added a Hardhat script deployAllBadges.ts to automate deployment of multiple ERC1155Soulbound badge contracts and a mock USDC contract, including setup for initial tokens and whitelisting. This script also outputs environment variables and verification commands for further setup.
  • Added a script createInitialRewards.ts to facilitate creation and funding of initial rewards in the Rewards contract, including logic for ERC20 and ERC1155 deposits and (commented) reward token creation.
  • Introduced a script checkApprovals.ts to check approval status and balances for a target wallet across multiple badge contracts, aiding in troubleshooting and setup.
  • Updated Hardhat configuration to allow unlimited contract size on the local hardhat network, improving local development flexibility.

@ogarciarevett ogarciarevett self-assigned this Feb 4, 2026
Copilot AI review requested due to automatic review settings February 4, 2026 14:56
@openzeppelin-code
Copy link

openzeppelin-code bot commented Feb 4, 2026

Fix/add missing func

Generated at commit: 616a449a8025d44581ace8231279fe7c2b4a6600

🚨 Report Summary

Severity Level Results
Contracts Critical
High
Medium
Low
Note
Total
2
3
0
10
41
56
Dependencies Critical
High
Medium
Low
Note
Total
1
0
0
0
0
1

For more details view the full report in OpenZeppelin Code Inspector

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR updates the Rewards system to support a unified treasury for ERC20/ERC721/ERC1155 (including reservation tracking) and adds tooling/tests around the new treasury balance reporting, while also updating deployment configuration/constants for new contracts on Arbitrum.

Changes:

  • Converted Rewards to a UUPS-upgradeable contract and added NFT (ERC721/ERC1155) treasury reservation + balance reporting via getAllTreasuryBalances.
  • Expanded test coverage for soulbound + NFT treasury flows (reserve/withdraw/claim) and added multiple Hardhat scripts for deployment/setup/verification.
  • Updated Arbitrum deployment/upgrade configuration and constructor-arg constants to include GReceipts and new token/address parameters.

Reviewed changes

Copilot reviewed 18 out of 18 changed files in this pull request and generated 17 comments.

Show a summary per file
File Description
test/rewardsSoulbound.test.ts Updates Rewards deployment to UUPS proxy and adds tests for getAllTreasuryBalances + ERC1155 reservation tracking.
test/rewardsNftTreasury.test.ts New suite validating ERC721/ERC1155 treasury reservation, protection on withdraw, and claim distribution flows.
scripts/verifyRewards.ts Adds a verification script to inspect on-chain Rewards state including getAllTreasuryBalances.
scripts/setupWalletForRewards.ts Adds helper script to whitelist/mint assets to a target wallet for rewards setup.
scripts/setupUSDCReward.ts Adds helper script to deposit USDC and create a USDC reward.
scripts/setupAllRewards.ts Adds an end-to-end setup script for multiple badge rewards + USDC reward creation.
scripts/depositExtraUSDC.ts Adds helper script to top up USDC treasury and inspect available/reserved balances.
scripts/deployRewardsWithRoles.ts Adds deployment script intended to deploy AccessToken/Rewards and grant roles.
scripts/deployRewardsUUPS.ts Adds UUPS deployment script for Rewards and initial token whitelisting.
scripts/deployAllBadges.ts Adds script to deploy multiple badge contracts + MockUSDC and perform basic setup.
scripts/createInitialRewards.ts Adds script to fund treasury (ERC20/1155) and prepare initial rewards creation.
scripts/checkApprovals.ts Adds script to inspect badge approvals/balances for a wallet.
hardhat.config.ts Enables unlimited contract size on local hardhat network for development.
contracts/upgradeables/soulbounds/Rewards.sol Core changes: UUPS upgradeability, unified token whitelist with types, NFT reservation accounting, and getAllTreasuryBalances.
contracts/upgradeables/ercs/ERCWhitelistSignatureUpgradeable.sol Tracks whitelist signer list for enumeration and updates storage gap.
constants/upgrades/index.ts Adds upgrade configuration entry for GReceipts on Arbitrum One.
constants/deployments/deployments-arbitrum-one.ts Adds GReceipts deployment config on Arbitrum One.
constants/constructor-args.ts Updates addresses/args for Arbitrum networks and adds GReceiptsArgs.ARBITRUM_ONE.
Comments suppressed due to low confidence (7)

contracts/upgradeables/soulbounds/Rewards.sol:66

  • Rewards is now UUPS/Initializable but the contract lacks an implementation constructor that disables initializers. Without constructor() { _disableInitializers(); }, someone can initialize the implementation contract directly and grant themselves roles, which is a common UUPS footgun. Also consider importing UUPSUpgradeable from @openzeppelin/contracts-upgradeable/... for consistency with the other upgradeable base contracts.
    contracts/upgradeables/soulbounds/Rewards.sol:403
  • _countUniqueErc1155TokenIds() allocates itemIds.length * 10 slots for tracking unique (address,tokenId) pairs. Since there is no hard cap of 10 ERC1155 rewards per item, count++ can exceed the allocated length and revert at runtime. Consider a two-pass approach: first count the total number of ERC1155 reward entries across all itemIds to size the arrays, or maintain explicit tracking of seen pairs in storage when rewards are created.
    contracts/upgradeables/soulbounds/Rewards.sol:240
  • getAllTreasuryBalances() can return multiple entries for the same ERC1155 contract address (different token IDs), but the return values don’t include the ERC1155 tokenId for each row. That makes the result ambiguous for consumers (duplicate addresses with different balances/reserved) and hard to act on (e.g., withdraw a specific id). Consider returning a parallel uint256[] tokenIds (0 for ERC20/ERC721) or a struct/tuple that includes (tokenAddress, tokenId, type, balances, metadata) per entry.
    contracts/upgradeables/soulbounds/Rewards.sol:271
  • getAllTreasuryBalances() can revert with an out-of-bounds write: totalCount is computed as erc20AndErc721Count + _countUniqueErc1155TokenIds(), but the loop always writes addresses[currentIndex] = tokenAddress even for ERC1155 entries. If only ERC1155 tokens are whitelisted and there are no rewards yet (so totalCount == 0), this write reverts. Move the assignment inside the ERC20/ERC721 branches (or guard with if (currentIndex < totalCount)), and ensure ERC1155-only whitelists return empty arrays rather than reverting.
    contracts/upgradeables/soulbounds/Rewards.sol:128
  • Introducing tokenTypes changes runtime assumptions for already-deployed proxies: existing whitelistedTokenList entries (from before this mapping existed) will have tokenTypes[token] == 0 (ETHER), which can cause getAllTreasuryBalances() to miscount/allocate arrays and potentially revert. If this contract is being upgraded in-place, add a migration path (e.g., manager-only function to backfill tokenTypes for existing whitelisted tokens) or make getAllTreasuryBalances resilient to unset types.
    contracts/upgradeables/soulbounds/Rewards.sol:666
  • whitelistToken now allows whitelisting ERC721/ERC1155, but depositToTreasury, getTreasuryBalance, and related treasury helpers still assume the token is ERC20 (they call SafeERC20 / IERC20.balanceOf). This makes it easy to whitelist an NFT and then hit confusing reverts when using treasury ERC20 flows. Consider enforcing _type == LibItems.RewardType.ERC20 inside depositToTreasury (and other ERC20-only helpers) or splitting the API so NFT treasury operations cannot be mixed with ERC20 deposit calls.
    contracts/upgradeables/soulbounds/Rewards.sol:720
  • removeTokenFromWhitelist enforces balance == 0 for ERC20 and ERC721, but for ERC1155 it only checks erc1155TotalReserved and does not prevent removing a token while the contract still holds ERC1155 balances. That can make assets harder to discover/operate on (e.g., getAllTreasuryBalances only walks whitelisted tokens) and blocks the ERC1155-specific withdraw helper which requires whitelistedTokens[_token]. If you can’t enumerate all ERC1155 IDs, consider tracking received ERC1155 IDs in storage (via ERC1155Receiver hooks) and preventing removal while any tracked balance > 0, or document/handle the removal semantics explicitly.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@ogarciarevett ogarciarevett merged commit 1eec254 into main Feb 4, 2026
1 check passed
@ogarciarevett ogarciarevett deleted the fix/add-missing-func branch February 4, 2026 18:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants